/**
 * 达尔文进化论
 */

class singleCell {
  _name: string;

  constructor(name: string) {
    this._name = name;
  }

  swim() {
    // @ts-ignore
    console.log(this._name + ": I can swimming");
  }

}
const cell_1 = new singleCell("cell1");
cell_1.swim();


class Fish extends singleCell {
  _weight: number;

  constructor(name: string, weight: number) {
    super(name);
    this._weight = weight;
  }

  eat() {
    // @ts-ignore
    console.log("I can eat others!");
  }
}

const shark = new Fish("shark", 50);
shark.eat();

class Animal extends Fish {
  private readonly run: boolean; // run是动物的私有属性不能够被对象调用
  constructor(name: string, weight: number, runBol: boolean) {
    super(name, weight);
    this.run = runBol;
  }

  walk() {
    // @ts-ignore
    console.log(`${this._name} ${this.run ? "can" : "can't"} walk on the road!`);
  }
}

const monkey = new Animal("monkey", 80, false);

monkey.eat();
monkey.walk();

//定义人的其他信息接口
interface othersInfo {
  firstName: string,
  lastName: string,
  age: number,
  sex: string,
}

class people extends Animal {
  _language: string;
  private othersInfo: othersInfo;

  constructor(name: string, weight: number, language: string, runBol: boolean, othersInfo: othersInfo) {
    super(name, weight, runBol);
    this._language = language;
    this.othersInfo = othersInfo;
    // @ts-ignore
    console.log(this._name + " can talk with" + language);
  }


}

const yellow_Info: othersInfo = {
  firstName: "x-",
  lastName: "xx",
  age: 10,
  sex: "man"
};

export const yellow_people = new people("people_1", 80, "中文", true, yellow_Info);

